<template>
  <div class="demo">
    <!-- swiper -->
    <swiper class="cardTop" :options="swiperOption" ref="mySwiper">
      <swiper-slide
        class="cardItem"
        v-for="(item, index) in 4"
        :key="index"
      >
        <div class="box">
          {{index}}
        </div>
        <!-- 标记页数 -->
        <!-- <div class="swiper-pagination" slot="pagination"></div> -->
        <!-- 左右箭头 -->
        <!-- <div
          class="swiper-button-prev swiper-button-black"
          slot="button-prev"
        ></div> -->
        <!-- <div
          class="swiper-button-next swiper-button-black"
          slot="button-next"
        ></div> -->
      </swiper-slide>
    </swiper>
  </div>
</template>

<script>
import { swiper, swiperSlide } from "vue-awesome-swiper";
import "swiper/dist/css/swiper.css";

export default {
  //import引入的组件需要注入到对象中才能使用
  components: {
    swiper,
    swiperSlide,
  },
  // 数据
  data() {
    return {
      // 初始化swiper
      swiperOption: {
        // 设置slider容器能够同时显示的slides数量(carousel模式)
        slidesPerView: 'auto',
        
        // 在slide之间设置距离（单位px）
        spaceBetween: 30,
        
      },
    };
  },
  //计算属性-监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //方法集合
  methods: {},
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {
    window.that = this
  },
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style scoped>
.cardTop {
  width: 100%;
}
.box {
  width: 500px;
  background-color: aqua;
}
.cardTop>>>.swiper-slide {
  width: 80% !important;
}
</style>